package com.jinly.ryder.common.service.mapping;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mapstruct.MapperConfig;
import org.mapstruct.Mapping;

import java.util.List;

@MapperConfig
public interface BaseModelMapping<M, E> {

    M toModel(E entity);

    List<M> toModelList(List<E> entity);

    @Mapping(target = "created", ignore = true)
    @Mapping(target = "updated", ignore = true)
    E toEntity(M model);

    @Mapping(target = "created", ignore = true)
    @Mapping(target = "updated", ignore = true)
    List<E> toEntityList(List<M> modelList);

    Page<M> toModelPage(Page<E> entity);
}
